import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const home = () => import('./views/Home')
const homenews = () => import('./views/HomeNews')
const homemsg = () => import('./views/HomeMsg')
const about = () => import('./views/About')
const product = () => import('./views/Product')
const profile = () => import('./views/Profile')

const routes = [
    {
        path: '',
        redirect: '/home'
    },
    {
        path: '/home',
        name: 'home',
        meta:{
            title: '首页',
        },
        component: home,
        children: [
            {
                path: '',
                redirect: 'news'
            },

            {
                path: 'news',
                name: 'homenews',
                meta:{
                    title: '首页新闻',
                },
                component: homenews
            },
            {
                path: 'msg',
                name: 'homemsg',

                meta:{
                    title: '首页信息',
                },
                component: homemsg
            }
        ]
    },
    {
        path: '/about',
        name: 'about',
        meta:{
            title: '关于',
        },
        component: about,
        beforeEnter: (to, from, next) => {
            console.log(to);
            next();
        }
    },
    {
        path: '/product/:id',
        name: 'Product',

        meta:{
            title: '产品',
        },
        component: product
    },
    {
        path: '/profile',
        name: 'profile',
        meta:{
            title: '档案'
        },
        component: profile
    },

]

export default new Router({
    mode: 'history',
    base: process.env.BASE_URL,
    routes,
    linkActiveClass: 'active'
})
